﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using LTorrent.Extensions;

namespace LTorrent.Peers
{
    class HaveMessage:IPeerMessages
    {
        protected readonly Byte[] LengthPrefix = { 0, 0, 0, 5, 4 };
        protected MemoryStream _Message;
        public HaveMessage(UInt32 Index)
        {
            _Message = new MemoryStream();
            _Message.Write(LengthPrefix,0, LengthPrefix.Length);
            Byte[] temp = Index.toNetworkOrder();
            _Message.Write(temp, 0, temp.Length);
        }
         ~HaveMessage()
        {
            _Message.Close();
        }
        public byte[] Message
        {
            get { return _Message.ToArray(); }
        }
    }
}
